package com.example.demo;

import com.example.demo.Component.UserComponent;
import com.example.demo.Configuration.UserConfiguration;
import com.example.demo.Repository.UserRepository;
import com.example.demo.Service.UserService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;

@SpringBootApplication
public class SpringIocDemoApplication {

	public static void main(String[] args) {
		ApplicationContext context =  SpringApplication.run(SpringIocDemoApplication.class, args);
//		UserController bean = context.getBean(UserController.class);
//		System.out.println(bean);
//		bean.sayHi();
//
//		UserController userController = (UserController) context.getBean("userController");
//		System.out.println(userController);
//		userController.sayHi();
//
//		UserController userController1 = context.getBean("userController", UserController.class);
//		System.out.println(userController1);
//		userController1.sayHi();
		UserComponent bean1 = context.getBean(UserComponent.class);
		bean1.sayComponent();

		UserConfiguration bean2 = context.getBean(UserConfiguration.class);
		bean2.sayConfiguration();

		UserRepository bean3 = context.getBean(UserRepository.class);
		bean3.sayRepository();

		UserService bean4 = context.getBean(UserService.class);
		bean4.sayService();
	}

}
